package com.wcar.order.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wcar.common.entity.Order;
import com.wcar.common.entity.Product;
import com.wcar.common.entity.ProductOrder;
import com.wcar.common.entity.ProductReview;
import com.wcar.common.vo.Result;
import com.wcar.order.service.impl.OrderServiceImpl;
import com.wcar.order.vo.OrderMobileVo;
import com.wcar.order.vo.OrderVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private OrderServiceImpl orderService;
    @RequestMapping("/OrderManagement")
    public Result<Page<ProductOrder>> OrderManagement(@RequestBody OrderVo orderVo) {
        return orderService.getOrderList(orderVo);
    }
    @PostMapping("/OrderMobile")
    public Result<List<ProductOrder>> OrderMobile(@RequestBody OrderMobileVo orderVo) {
        return orderService.getOrderMobile(orderVo);
    }
    @PostMapping("/updateStatus")
    public Result updateStatus(@RequestParam Integer id) {
        return orderService.updateStatus(id);
    }
    @PostMapping("/updateBuyStatus")
    public Result updateBuyStatus(@RequestParam Integer id) {
        return orderService.updateBuyStatus(id);
    }
    @GetMapping("/selectOneOrder")
    public Result<ProductOrder> selectOneOrder(@RequestParam Integer id) {
        return orderService.selectOneOrder(id);
    }
    @PostMapping("/IntegralPay")
    public Result IntegralPay(@RequestBody ProductOrder order) {
        return orderService.IntegralPay(order);
    }
    @GetMapping("/PayFinish")
    public Result<Product> PayFinish(@RequestParam Integer id) {
        return orderService.PayFinish(id);
    }
    @PostMapping("/createWDPay")
    public Result createWDPay(@RequestBody ProductOrder order) {
        return orderService.createWDPay(order);
    }
    @PostMapping("/createWeChat/{orderNo}")
    public Result createWeChat(@PathVariable String orderNo){
        return orderService.createWeChat(orderNo);
    }
    @PostMapping("/queryWeChatPayStatus/{orderNo}")
    public Result queryWeChatPayStatus(@PathVariable String orderNo){
        return orderService.queryWeChatPayStatus(orderNo);
    }
    @PostMapping("/queryWDPayStatus")
    public Result queryWDPayStatus(@RequestBody ProductOrder productOrder){
        return orderService.queryWDPayStatus(productOrder);
    }
    @DeleteMapping("/delete")
    public Result delete(@RequestParam Integer id) {
        return orderService.delete(id);
    }
    @PostMapping("/insert")
    public Result<Order> insert(@RequestBody ProductReview productReview) {
        return orderService.insert(productReview);
    }
    @GetMapping("/updateReviewStatus")
    public Result updateReviewStatus(@RequestParam Integer id) {
        return orderService.updateReviewStatus(id);
    }
    @PostMapping("/cancelOrder")
    public Result cancelOrder(@RequestBody ProductOrder productOrder){
        return orderService.cancelOrder(productOrder);
    }
    //发货
    @PostMapping("/sendOutGoods")
    public Result sendOutGoods(@RequestBody ProductOrder productOrder){
        return orderService.sendOutGoods(productOrder);
    }
}
